<template>
  <div id="app" v-cloak>
    <!-- 骨架屏 -->
    <div v-if="loading" class="skeleton-container">
      <div class="skeleton-banner"></div>
      <div class="skeleton-inquiry"></div>
      <div class="skeleton-project"></div>
      <div class="skeleton-service"></div>
    </div>

    <div v-if="!loading" class="main-content">
      <!-- 轮播图部分 -->
      <div class="banner-container">
        <div class="swiper-container">
          <div class="swiper-wrapper">
            <div
              v-for="(item, index) in banner_box"
              :key="index"
              class="swiper-slide banner-slide"
            >
              <div class="banner-img">
                <img :src="baseUrl + item.imageUrl" :alt="item.title" />
              </div>

              <div class="banner-content">
                <h1 class="banner-title">{{ item.title }}</h1>

                <!-- 优化的步骤条 -->
                <div class="divider-line">
                  <div class="step-points">
                    <div
                      v-for="(step, index) in steps"
                      :key="index"
                      class="step-point"
                      :class="{ 'active': currentStep >= index }"
                    >
                      <span class="point"></span>
                      <span class="step-text">{{ step.label }}</span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div
        class="rail-service"
        v-for="item in aslMyaslIntroList"
        :key="item.id"
      >
        <div class="service-container">
          <div class="service-header">
            <div class="tit-line">
              <span class="tit-line1"></span>
              <span class="tit-line2"></span>
            </div>
            <h2 class="solve-tit">{{item.title}}</h2>
          </div>

          <div
            class="service-features"
            v-html="item.content">
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { bannerList } from "@/api/banner/banner"
import { getAllContents } from "../../../api/aslMyaslIntro/aslMyaslIntro";

export default {
  data() {
    return {
      loading: true,
      baseUrl: process.env.VUE_APP_BASE_API,
      banner_box: [],
      aslMyaslIntroList: [],
      currentStep: 2,
      steps: [
        { label: this.$t('contentDetails.logInToYourYyASLAccount') },
        { label: this.$t('contentDetails.quickQuoteInJustSeconds') },
        { label: this.$t('contentDetails.orderAdministration') }
      ]
    }
  },
  async created() {
    await Promise.all([
      this.getBannerList(),
      this.getAllContents()
    ]);
    this.loading = false;
  },
  methods: {
    /** 查询myASL介绍列表 */
    getAllContents() {
      return getAllContents().then(response => {
        this.aslMyaslIntroList = response.data;
      })
    },
    // 轮播图
    getBannerList() {
      return bannerList(12).then(response => {
        this.banner_box = response.data;
      })
    }
  }
}
</script>

<style scoped lang="scss">
[v-cloak] {
  display: none;
}

/* 骨架屏样式 */
.skeleton-container {
  width: 100%;
  min-height: 100vh;

  .skeleton-banner {
    height: 500px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
  }

  .skeleton-inquiry,
  .skeleton-project,
  .skeleton-service {
    height: 300px;
    margin-top: 30px;
    background: #f5f5f5;
    border-radius: 8px;
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.service-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.service-header {
  text-align: left;
}

.service-features {
  padding: 30px 0;
}

.rail-service {
  padding: 30px 0;
  background: #fff;
  border-radius: 12px;
}

.tit-line {
  display: flex;
  justify-content: left;
  margin-bottom: 20px;
}

.tit-line1, .tit-line2 {
  height: 6px;
  background: #fe3231;
  border-radius: 3px;
}

.tit-line1 {
  width: 60px;
}

.tit-line2 {
  width: 10px;
  margin-left: 10px;
}

.solve-tit {
  font-size: 32px;
  font-weight: 700;
  color: #222;
  margin-bottom: 15px;
  text-align: left;
  line-height: 1.3;
}

/* 轮播图样式 */
.banner-container {
  position: relative;
  width: 100%;
  min-height: 500px;
  overflow: hidden;
}

.swiper-container {
  width: 100%;
  height: 100%;
}

.banner-slide {
  position: relative;
  width: 100%;
  height: 100%;
}

.banner-img img {
  width: 100%;
  height: 100%;
  min-height: 500px;
  object-fit: cover;
}

.banner-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  width: 100%;
  padding: 0 20px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.banner-title {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: 1px;
}

/* 优化的步骤条 */
.divider-line {
  position: relative;
  margin: 50px auto;
  width: 70%;
  z-index: 10;

  .step-points {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    width: 100%;
  }
}

.step-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 33.33%;
  padding-bottom: 10px;
}

.point {
  display: block;
  width: 16px;
  height: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
  margin-bottom: 15px;
  position: relative;
  transition: all 0.4s ease;
}

.step-point.active .point {
  background: #ff4d4f;
  transform: scale(1.3);
  box-shadow: 0 0 0 6px rgba(255, 77, 79, 0.3);

  &::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
  }
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  70% { transform: scale(1.2); opacity: 0.2; }
  100% { transform: scale(1.3); opacity: 0; }
}

.step-text {
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-align: center;
  max-width: 90%;
  line-height: 1.4;
  margin-top: 20px;
}

/* ================= 移动端适配优化 ================= */
@media (max-width: 1200px) {
  .divider-line {
    width: 85%;
  }

  .banner-title {
    font-size: 36px;
  }

  .step-text {
    font-size: 16px;
  }
}

@media (max-width: 992px) {
  .solve-tit {
    font-size: 28px;
  }

  .banner-title {
    font-size: 32px;
  }

  .divider-line {
    width: 90%;
  }

  .service-features {
    font-size: 17px;
  }

  .rail-service {
    padding: 20px 0;
  }
}

@media (max-width: 768px) {
  .banner-container {
    min-height: 400px;
  }

  .banner-img img {
    min-height: 400px;
  }

  .banner-title {
    font-size: 24px;
    letter-spacing: 0.5px;
    line-height: 1.3;
  }

  .banner-content {
    padding: 0 15px;
    top: 65%;
  }

  /* 步骤指示器移动端垂直布局 */
  .divider-line {
    margin: 40px auto;
    width: 100%;
    max-width: 360px;

    .step-points {
      flex-direction: column;
      align-items: center;
      gap: 30px;
    }
  }

  .step-point {
    width: 100%;
    padding-bottom: 0;
    flex-direction: row;
    justify-content: flex-start;

    &:not(:last-child):after {
      content: '';
      position: absolute;
      top: 8px;
      left: 48px;
      right: 0;
      height: 1px;
      background: rgba(255,255,255,0.3);
      z-index: -1;
    }
  }

  .point {
    margin-right: 20px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .step-text {
    text-align: left;
    margin-top: 0;
    padding-right: 20px;
    font-size: 16px;
  }

  .solve-tit {
    font-size: 26px;
    margin-bottom: 12px;
  }

  .tit-line {
    //justify-content: center;
    margin-bottom: 15px;
  }

  .tit-line1 {
    width: 50px;
  }

  .tit-line2 {
    width: 8px;
    margin-left: 8px;
  }

  .service-header {
    text-align: center;
  }
}

@media (max-width: 576px) {
  .banner-container {
    min-height: 350px;
  }

  .banner-img img {
    min-height: 350px;
  }

  .banner-title {
    font-size: 24px;
    margin-bottom: .3rem;
  }

  .solve-tit {
    font-size: 20px;
  }

  .divider-line {
    margin: 10px auto;

    .step-points {
      gap: 24px;
    }
  }

  .point {
    width: 14px;
    height: 14px;
    margin-right: 15px;
  }

  .step-point.active .point {
    box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.3);
  }

  .step-text {
    font-size: 14px;
  }

  .step-point {
    &:not(:last-child):after {
      left: 42px;
    }
  }

  .service-container {
    padding: 0 15px;
  }

  .service-features {
    padding: 20px 0;
    font-size: 16px;
    line-height: 1.7;
  }

  .skeleton-banner {
    height: 400px;
  }

  .skeleton-inquiry,
  .skeleton-project,
  .skeleton-service {
    height: 250px;
    margin-top: 20px;
  }
}

@media (max-width: 480px) {
  .banner-container {
    min-height: 300px;
  }

  .banner-img img {
    min-height: 300px;
  }

  .banner-title {
    font-size: 20px;
  }

  .point {
    width: 12px;
    height: 12px;
    margin-right: 12px;
  }

  .step-text {
    font-size: 13px;
  }

  .step-point {
    &:not(:last-child):after {
      left: 35px;
    }
  }

  .rail-service {
    padding: 15px 0;
  }
}
</style>
